//
//  TBPresentationController.swift
//  新浪微博
//
//  Created by bin on 16/1/23.
//  Copyright © 2016年 XMG. All rights reserved.
//

import UIKit

class TBPresentationController: UIPresentationController {

    override func containerViewWillLayoutSubviews() {
        super.containerViewWillLayoutSubviews()
        coverView.frame = (containerView?.bounds)!
        containerView?.insertSubview(coverView, atIndex: 0)
        presentedView()?.frame = CGRect(x: 100, y: 56, width: 200, height: 200)
    }
    
    private lazy var coverView: UIView = {
    
        let view1 = UIView()
        view1.backgroundColor = UIColor(white: 0.8, alpha: 0.5)
        view1.addGestureRecognizer(UITapGestureRecognizer(target: self, action: Selector("dismissPresentedView")))
        return view1
    }()
    
    func dismissPresentedView(){
        presentedViewController.dismissViewControllerAnimated(true, completion: nil)
    }
}
